package com.game.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.game.common.utils.DateUtils;
import com.game.system.domain.game.CodeKey;
import com.game.system.mapper.CodeKeyMapper;
import com.game.system.service.ICodeKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 卡密Service业务层处理
 *
 * @author Mr.Liu
 * @date 2025-03-18
 */
@Service
public class CodeKeyServiceImpl extends ServiceImpl<CodeKeyMapper, CodeKey> implements ICodeKeyService {
    @Autowired
    private CodeKeyMapper codeKeyMapper;

    /**
     * 查询卡密
     *
     * @param id 卡密主键
     * @return 卡密
     */
    @Override
    public CodeKey selectCodeKeyById(Long id) {
        return codeKeyMapper.selectCodeKeyById(id);
    }

    /**
     * 查询卡密列表
     *
     * @param codeKey 卡密
     * @return 卡密
     */
    @Override
    public List<CodeKey> selectCodeKeyList(CodeKey codeKey) {
        return codeKeyMapper.selectCodeKeyList(codeKey);
    }

    /**
     * 新增卡密
     *
     * @param codeKey 卡密
     * @return 结果
     */
    @Override
    public int insertCodeKey(CodeKey codeKey) {
                codeKey.setCreateTime(DateUtils.getNowDate());
            return codeKeyMapper.insertCodeKey(codeKey);
    }

    /**
     * 修改卡密
     *
     * @param codeKey 卡密
     * @return 结果
     */
    @Override
    public int updateCodeKey(CodeKey codeKey) {
                codeKey.setUpdateTime(DateUtils.getNowDate());
        return codeKeyMapper.updateCodeKey(codeKey);
    }

    /**
     * 批量删除卡密
     *
     * @param ids 需要删除的卡密主键
     * @return 结果
     */
    @Override
    public int deleteCodeKeyByIds(Long[] ids) {
        return codeKeyMapper.deleteCodeKeyByIds(ids);
    }

    /**
     * 删除卡密信息
     *
     * @param id 卡密主键
     * @return 结果
     */
    @Override
    public int deleteCodeKeyById(Long id) {
        return codeKeyMapper.deleteCodeKeyById(id);
    }
}
